package com.yc.spring.bmi;

import com.yc.spring.BeanConfig;
import com.yc.spring.bank.bean.Record;
import com.yc.spring.bbs.bean.Board;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.stereotype.Component;
import org.springframework.test.context.ContextConfiguration;

import javax.annotation.Resource;

@Configuration // 等效于 beans.xml
@ComponentScan("com.yc.spring") // 包扫描
@EnableAspectJAutoProxy
// 设置配置文件 xml 和注解
@ContextConfiguration(classes = BeanConfig.class)
@Component
public class Demo {
    /**
     * div, header, footer, main 语义标签
     */

    @Resource
    Board board;

    @Autowired   // 有限byType, 如果失败 byName
    public Record record;

    @Autowired
    Record record1;


    @Autowired
    @Qualifier("record1")
    Record record2;

    @Resource(name = "record1") // J2ee提供
    Record record3;
}
